package com.ruoyi.info.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.info.domain.FhInfoRankrecord;
import com.ruoyi.info.service.IFhInfoRankrecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * 排名记录Controller
 * 
 * @author ruoyi
 * @date 2024-11-09
 */
@RestController
@RequestMapping("/info/rankrecord")
public class FhInfoRankrecordController extends BaseController
{
    @Autowired
    private IFhInfoRankrecordService fhInfoRankrecordService;

    /**
     * 查询排名记录列表
     */
    @PreAuthorize("@ss.hasPermi('info:rankrecord:list')")
    @GetMapping("/list")
    public TableDataInfo list(FhInfoRankrecord fhInfoRankrecord)
    {
        startPage();
        List<FhInfoRankrecord> list = fhInfoRankrecordService.selectFhInfoRankrecordList(fhInfoRankrecord);
        return getDataTable(list);
    }

    /**
     * 导出排名记录列表
     */
    @PreAuthorize("@ss.hasPermi('info:rankrecord:export')")
    @Log(title = "排名记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FhInfoRankrecord fhInfoRankrecord) throws IOException {
        List<FhInfoRankrecord> list = fhInfoRankrecordService.selectFhInfoRankrecordList(fhInfoRankrecord);
        ExcelUtil<FhInfoRankrecord> util = new ExcelUtil<FhInfoRankrecord>(FhInfoRankrecord.class);
        util.exportExcel(response, list, "排名记录数据");
    }

    /**
     * 获取排名记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('info:rankrecord:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(fhInfoRankrecordService.selectFhInfoRankrecordById(id));
    }

    /**
     * 新增排名记录
     */
    @PreAuthorize("@ss.hasPermi('info:rankrecord:add')")
    @Log(title = "排名记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FhInfoRankrecord fhInfoRankrecord)
    {
        return toAjax(fhInfoRankrecordService.insertFhInfoRankrecord(fhInfoRankrecord));
    }

    /**
     * 修改排名记录
     */
    @PreAuthorize("@ss.hasPermi('info:rankrecord:edit')")
    @Log(title = "排名记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FhInfoRankrecord fhInfoRankrecord)
    {
        return toAjax(fhInfoRankrecordService.updateFhInfoRankrecord(fhInfoRankrecord));
    }

    /**
     * 删除排名记录
     */
    @PreAuthorize("@ss.hasPermi('info:rankrecord:remove')")
    @Log(title = "排名记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(fhInfoRankrecordService.deleteFhInfoRankrecordByIds(ids));
    }
}
